#include <iostream>
#include <math.h>
using namespace std;
class hcn
{
private:
	double dai, rong;
public:
	hcn ();
	hcn (double _dai, double _rong)
	{
		if(_dai>=0&&_rong>=0)
		{
			dai=_dai;
			rong=_rong;
		}
		else
		{
			cout<<"do dai khong duoc la so am! "<<endl;
			dai=0; rong=0;
		}
	}
	double getdai();
	double getrong();
	void setdai(double _dai);
	void setrong(double _rong);
	double tinhduongcheo();
	bool kiemtrahv();
};

hcn::hcn()
{
	dai=0;
	rong=0;
}

double hcn::getdai ()
{
	return dai;
}

double hcn::getrong ()
{

	return rong;
}

void hcn::setdai(double _dai)
{
	dai=_dai;
}
void hcn::setrong(double _rong)
{
	rong=_rong;
}



double hcn::tinhduongcheo()
{
	return	sqrt(dai*dai+rong*rong);
}

bool hcn::kiemtrahv()
{
	if (dai>0&&rong>0&&dai==rong)
		return 1;
	else
		return 0;
}

int main()
{
	int a,i,j=0;
	double d,r;	
	hcn h[100];
	/*
	hcn hcn1(3,4), hcn2(4,4), hcn3(0,0), hcn4(-6,-8);
	cout<<"duong cheo hinh chu nhat (3,4): "<<hcn1.tinhduongcheo()<<endl;
	if(hcn1.kiemtrahv()==true)
	{
		cout<<"day la hinh vuong"<<endl;
	}
	else
		cout<<"khong fai hinh vuong"<<endl;
	*/
	cout<<"ban muon nhap bao nhieu hinh? ";
	cin>>a;
	for(i=1;i<=a;i++)
	{
		cout<<"hinh thu "<<i<<endl;
		cout<<"chieu dai: ";
		cin>>d;
		h[i].setdai(d);
		cout<<"chieu rong: ";
		cin>>r;
		h[i].setrong(r);
		cout<<endl;

		cout<<"duong cheo hinh "<<i<<" la: "<<h[i].tinhduongcheo();
		if(h[i].kiemtrahv()==true)
		{
			cout<<" -- day la hinh vuong"<<endl;
		}
		else
			cout<<" -- khong fai hinh vuong"<<endl;
	}

	system("pause");
	return 0;
}